import 'dart:convert' show json;
//搜索结果
class SearchModel {
  String? keyWord;
  String? resultPageUrl;
  List<SearchItem?>? data;

  SearchModel.fromParams({this.resultPageUrl, this.data});

  factory SearchModel(Object jsonStr) => jsonStr is String ? SearchModel.fromJson(json.decode(jsonStr)) : SearchModel.fromJson(jsonStr);

  static SearchModel? parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : SearchModel(jsonStr);

  SearchModel.fromJson(jsonRes) {
    resultPageUrl = jsonRes['resultPageUrl'];
    data = jsonRes['data'] == null ? null : [];
    for (var dataItem in data == null ? [] : jsonRes['data']){
      data!.add(dataItem == null ? null : SearchItem.fromJson(dataItem));
    }
  }

  @override
  String toString() {
    return '{"resultPageUrl": ${resultPageUrl != null?'${json.encode(resultPageUrl)}':'null'}, "data": $data}';
  }

  String toJson() => this.toString();
}

class SearchItem {

  bool? isBigIcon;
  String? code;
  String? districtname;
  String? imageUrl;
  String? price;
  String? sourceType;
  String? subImageUrl;
  String? type;
  String? url;
  String? word;
  String? zonename;

  SearchItem.fromParams({this.isBigIcon, this.code, this.districtname, this.imageUrl, this.price, this.sourceType, this.subImageUrl, this.type, this.url, this.word, this.zonename});

  SearchItem.fromJson(jsonRes) {
    isBigIcon = jsonRes['isBigIcon'];
    code = jsonRes['code'];
    districtname = jsonRes['districtname'];
    imageUrl = jsonRes['imageUrl'];
    price = jsonRes['price'];
    sourceType = jsonRes['sourceType'];
    subImageUrl = jsonRes['subImageUrl'];
    type = jsonRes['type'];
    url = jsonRes['url'];
    word = jsonRes['word'];
    zonename = jsonRes['zonename'];
  }

  @override
  String toString() {
    return '{"isBigIcon": $isBigIcon, '
        '"code": ${code != null?'${json.encode(code)}':'null'}, "districtname":'
        ' ${districtname != null?'${json.encode(districtname)}':'null'}, '
        '"imageUrl": ${imageUrl != null?'${json.encode(imageUrl)}':'null'},'
        ' "price": ${price != null?'${json.encode(price)}':'null'}, "sourceType":'
        ' ${sourceType != null?'${json.encode(sourceType)}':'null'}, "subImageUrl":'
        ' ${subImageUrl != null?'${json.encode(subImageUrl)}':'null'}, "type": '
        '${type != null?'${json.encode(type)}':'null'}, "url": ${url != null?'${json.encode(url)}':'null'},'
        ' "word": ${word != null?'${json.encode(word)}':'null'},'
        ' "zonename": ${zonename != null?'${json.encode(zonename)}':'null'}}';
  }

  String toJson() => this.toString();
}